package com.kuang.array;

import java.util.Arrays;

public class Demo07 {
    public static void main(String[] args) {
        int[] a = {1,8,5,3,9,6};
        int[]  sorted = sort(a);
        System.out.println(Arrays.toString(sorted));
    }

   public static int[] sort(int[] array){
       int temp = 0;
       for (int i = 0; i < array.length; i++) {
           boolean flag = false;
           for (int j = 0; j < array.length - i - 1; j++) {
               if (array[j] > array[j + 1]) {
                   temp = array[j];
                   array[j] = array[j + 1];
                   array[j + 1] = temp;
                   flag = true;
               }
           }
           if(flag == false){
               break;
           }
       }
       return array;
   }




}
